package com.imau.servlet;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

@WebServlet("/Response1")
public class Response1 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        this.doPost(request, response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        //1.设置响应头信息
        response.setHeader("content-type", "text/html;charset=UTF-8");

        //2.设置响应状态，一般不设置
        response.setStatus(200);

        //3.设置响应体
        response.getWriter().write("<h1>响应成功</h1>");

        //4.重定向到html页面
        response.sendRedirect("admin/a.html");
    }
}
